import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '@/views/user/login.vue'
import index from '@/views/home/index.vue'
import mainCount from '@/views/home/mainCount.vue'
import articleList from '@/views/article/articleList.vue'
import articleRelease from '@/views/article/articleRelease.vue'
import articleCategory from '@/views/article/articleCategory.vue'
import comment from '@/views/comment/comment.vue'
import user from '@/views/user/user.vue'

Vue.use(VueRouter)

const routes = [
  {
    name: 'login',
    path: '/login',
    component: login
  },
  {
    name: 'index',
    path: '/index',
    component: index,
    //二级路由
    children: [
      {
        name: 'mainCount',
        path: '/mainCount',
        component: mainCount
      },{
        name: 'articleList',
        path: '/articleList',
        component: articleList
      },{
        name: 'comment',
        path: '/comment',
        component: comment
      },{
        name: 'user',
        path: '/user',
        component: user
      },{
        name: 'articleRelease',
        path: '/articleRelease',
        component: articleRelease
      },{
        name: 'articleCategory',
        path: '/articleCategory',
        component: articleCategory
      },
      /* 当用户在二级路由输入/,就重定向到mainCount */
      {
        path:'/',
        redirect:'/mainCount'
      }
    ]
  },
  /* 当用户在一级路由输入/ ,就重定向到index.vue 二级路由 */
  {
    path:'/',
    redirect:'/index'
  }
]

const router = new VueRouter({
  routes
})

export default router
